//
//  cpxqTableViewController.m
//  hainingOASystem
//
//  Created by michael on 2017/11/16.
//  Copyright © 2017年 czd. All rights reserved.
//

#import "cpxqTableViewController.h"

@interface cpxqTableViewController ()

@end

@implementation cpxqTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.view.backgroundColor = [UIColor whiteColor];
  
        self.title = @"产品详情";
         _tableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, KScreenWidth, KScreenHeight- kTopHeight) style:UITableViewStylePlain];
    self.tableView.separatorStyle = UITableViewCellSeparatorStyleNone;

_tableView.dataSource = self;
_tableView.delegate = self;
[self.view addSubview:_tableView];
      [self requsetdata];
    // Uncomment the following line to preserve selection between presentations.
    // self.clearsSelectionOnViewWillAppear = NO;
    
    // Uncomment the following line to display an Edit button in the navigation bar for this view controller.
    // self.navigationItem.rightBarButtonItem = self.editButtonItem;
}
- (void)requsetdata{
    NSString *string = [NSString stringWithFormat:@"%@%@",kcpxq,_id];
[httpTool ZBPostNetDataWith:string withDic:nil andSuccess:^(NSDictionary* dictionary){
NSLog(@"%@",dictionary);
 _dic = dictionary;
         [self.tableView reloadData];
 
 }andFailure:^{

 }];

}
- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return  3;
}
- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
if (indexPath.row ==0) {
 UITableViewCell* cell = [[UITableViewCell alloc]init];
 cell.selectionStyle = UITableViewCellSelectionStyleNone;
 self.bgView  = [[UIView alloc]init];
       [cell.contentView addSubview:_bgView];
        self.bgView.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView.layer.shadowOffset = CGSizeMake(1,1);
    self.bgView.layer.shadowOpacity = 0.3;
    self.bgView.layer.shadowColor = [UIColor blackColor].CGColor;
        self.bgView.layer.cornerRadius = 5;
UILabel *label1 = [[UILabel alloc]init];

label1.frame = CGRectMake(10, 10, 100, 20);
label1.text = @"   基本信息";
label1.textColor = [UIColor blueColor];
     label1.font = [UIFont boldSystemFontOfSize:14];
    [_bgView addSubview:label1];
    UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, label1.bottom, KScreenWidth-10, 1)];
    
    view1.backgroundColor = [UIColor colorWithRed:213/225.0 green:213/225.0 blue:221/225.0 alpha:1];
    [_bgView addSubview:view1];
UILabel *label2 = [[UILabel alloc]init];
label2.frame = CGRectMake(label1.left, label1.bottom+10,label1.width, 20);
label2.text = @"产品名称";
label2.textColor = [UIColor grayColor];
     label2.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label2];
    UILabel *label3 = [[UILabel alloc]init];
    
label3.frame = CGRectMake(label2.right,label2.top, KScreenWidth-20-label2.width, 20);
label3.text = _dic[@"productName"];
label3.textColor = [UIColor blackColor];
label3.textAlignment = NSTextAlignmentLeft;
     label3.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]init];
label4.frame = CGRectMake(label1.left, label2.bottom,label1.width, 20);
label4.text = @"产品类型";
label4.textColor = [UIColor grayColor];
     label4.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]init];
label5.frame = CGRectMake(label4.right,label4.top, KScreenWidth-20-label2.width, 20);
label5.text = _dic[@"productType"];
label5.textColor = [UIColor blackColor];
label5.textAlignment = NSTextAlignmentLeft;
     label5.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]init];
label6.frame = CGRectMake(label4.left, label4.bottom,label1.width, 20);
label6.text = @"产品所属机构";
label6.textColor = [UIColor grayColor];
     label6.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label6];
    
    
    UILabel *label7 = [[UILabel alloc]init];
label7.frame = CGRectMake(label6.right,label6.top, KScreenWidth-20-label2.width, 20);
label7.text = _dic[@"name"];
label7.textAlignment = NSTextAlignmentLeft;
label7.textColor = [UIColor blackColor];
     label7.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label7];
 
 
    UILabel *label8 = [[UILabel alloc]init];
label8.frame = CGRectMake(label6.left, label6.bottom,label1.width, 20);
label8.text = @"产品有效期";

label8.textColor = [UIColor grayColor];
     label8.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label8];
    
    UILabel *label9 = [[UILabel alloc]init];
label9.frame = CGRectMake(label8.right,label8.top, KScreenWidth-20-label2.width, 20);
label9.text = _dic[@"haveTime"];
label9.textAlignment = NSTextAlignmentLeft;
label9.textColor = [UIColor blackColor];
     label9.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label9];
    
    
    UILabel *label10 = [[UILabel alloc]init];
label10.frame = CGRectMake(label8.left, label8.bottom,label1.width, 20);
label10.text = @"产品简介";
label10.textColor = [UIColor grayColor];
     label10.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label10];
    
      CGFloat titleSize = [OAToolBox sizebyText:_dic[@"productContent"] font:13 minsWidth:20];
    UILabel *label11 = [[UILabel alloc]init];
label11.frame = CGRectMake(label8.left, label10.bottom+10,KScreenWidth-20, titleSize);
label11.numberOfLines = 0;
label11.text = _dic[@"productContent"];
label11.textColor = [UIColor blackColor];
     label11.font = [UIFont systemFontOfSize:13];
    [_bgView addSubview:label11];
      self.bgView.frame =  CGRectMake(5, 5, KScreenWidth - 10, 150+titleSize+10);

    return cell;
    



}
if (indexPath.row ==1) {
 UITableViewCell* cell = [[UITableViewCell alloc]init];
 cell.selectionStyle = UITableViewCellSelectionStyleNone;
  self.bgView2  = [[UIView alloc]init];
       [cell.contentView addSubview:_bgView2];
        self.bgView2.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView2.layer.shadowOffset = CGSizeMake(1,1);
    self.bgView2.layer.shadowOpacity = 0.3;
    self.bgView2.layer.shadowColor = [UIColor blackColor].CGColor;
        self.bgView2.layer.cornerRadius = 5;
UILabel *label1 = [[UILabel alloc]init];
label1.frame = CGRectMake(10, 10, 100, 20);
label1.text = @"   贷款信息";
label1.textColor = [UIColor blueColor];
     label1.font = [UIFont boldSystemFontOfSize:14];
    [self.bgView2 addSubview:label1];
      UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, label1.bottom, KScreenWidth-10, 1)];
    
    view1.backgroundColor = [UIColor colorWithRed:213/225.0 green:213/225.0 blue:221/225.0 alpha:1];
    [_bgView2 addSubview:view1];
UILabel *label2 = [[UILabel alloc]init];
label2.frame = CGRectMake(label1.left, label1.bottom+10,label1.width, 20);
label2.text = @"贷款性质";
label2.textColor = [UIColor grayColor];
     label2.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label2];
        UILabel *label3 = [[UILabel alloc]init];

label3.frame = CGRectMake(label2.right,label2.top, KScreenWidth-20-label2.width, 20);
label3.text = _dic[@"loanCharacter"];
label3.textColor = [UIColor blackColor];
label3.textAlignment = NSTextAlignmentLeft;
     label3.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label3];
    
    UILabel *label4 = [[UILabel alloc]init];
label4.frame = CGRectMake(label1.left, label2.bottom,label1.width, 20);
label4.text = @"担保方式";
label4.textColor = [UIColor grayColor];
     label4.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label4];
    
    UILabel *label5 = [[UILabel alloc]init];
label5.frame = CGRectMake(label4.right,label4.top, KScreenWidth-20-label2.width, 20);
label5.text = _dic[@"guarantee"];
label5.textColor = [UIColor blackColor];
label5.textAlignment = NSTextAlignmentLeft;
     label5.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label5];
    
    UILabel *label6 = [[UILabel alloc]init];
label6.frame = CGRectMake(label4.left, label4.bottom,label1.width, 20);
label6.text = @"贷款金额";
label6.textColor = [UIColor grayColor];
     label6.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label6];
    
    
    UILabel *label7 = [[UILabel alloc]init];
label7.frame = CGRectMake(label6.right,label6.top, KScreenWidth-20-label2.width, 20);
label7.text = [NSString stringWithFormat:@"%@",_dic[@"amount"]];
label7.textAlignment = NSTextAlignmentLeft;
label7.textColor = [UIColor blackColor];
     label7.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label7];
 
 
    UILabel *label8 = [[UILabel alloc]init];
label8.frame = CGRectMake(label6.left, label6.bottom,label1.width, 20);
label8.text = @"贷款期限";

label8.textColor = [UIColor grayColor];
     label8.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label8];
    
    UILabel *label9 = [[UILabel alloc]init];
label9.frame = CGRectMake(label8.right,label8.top, KScreenWidth-20-label2.width, 20);
label9.text = [NSString stringWithFormat:@"%@",_dic[@"time"]];
label9.textAlignment = NSTextAlignmentLeft;
label9.textColor = [UIColor blackColor];
     label9.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label9];
    
    
    UILabel *label10 = [[UILabel alloc]init];
label10.frame = CGRectMake(label8.left, label8.bottom,label1.width, 20);
label10.text = @"贷款利率";
label10.textColor = [UIColor grayColor];
     label10.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label10];
    
         UILabel *label11 = [[UILabel alloc]init];
label11.frame = CGRectMake(label10.right,label10.top, KScreenWidth-20-label2.width, 20);
label11.text = [NSString stringWithFormat:@"%@",_dic[@"interestRates"]];
label11.textAlignment = NSTextAlignmentLeft;
label11.textColor = [UIColor blackColor];
     label11.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label11];
    
    
      UILabel *label12 = [[UILabel alloc]init];
label12.frame = CGRectMake(label10.left, label10.bottom,label1.width, 20);
label12.text = @"还款方式";
label12.textColor = [UIColor grayColor];
     label12.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label12];
    
         UILabel *label13 = [[UILabel alloc]init];
label13.frame = CGRectMake(label12.right,label12.top, KScreenWidth-20-label2.width, 20);
label13.text = [NSString stringWithFormat:@"%@",_dic[@"repayment"]];
label13.textAlignment = NSTextAlignmentLeft;
label13.textColor = [UIColor blackColor];
     label13.font = [UIFont systemFontOfSize:13];
    [self.bgView2 addSubview:label13];
          self.bgView2.frame =  CGRectMake(5, 5, KScreenWidth - 10, 160);

    
    return cell;
    



}else{
 UITableViewCell* cell = [[UITableViewCell alloc]init];
 cell.selectionStyle = UITableViewCellSelectionStyleNone;
 self.bgView3  = [[UIView alloc]init];
       [cell.contentView addSubview:_bgView3];
        self.bgView3.backgroundColor = [UIColor whiteColor];
    //给bgView边框设置阴影
    self.bgView3.layer.shadowOffset = CGSizeMake(1,1);
    self.bgView3.layer.shadowOpacity = 0.3;
    self.bgView3.layer.shadowColor = [UIColor blackColor].CGColor;
        self.bgView3.layer.cornerRadius = 5;
UILabel *label1 = [[UILabel alloc]init];
label1.frame = CGRectMake(10, 10, 100, 20);
label1.text = @"   其他";
label1.textColor = [UIColor blueColor];
     label1.font = [UIFont boldSystemFontOfSize:14];
    [_bgView3 addSubview:label1];
      UIView *view1 = [[UIView alloc]initWithFrame:CGRectMake(0, label1.bottom, KScreenWidth-10, 1)];
    
    view1.backgroundColor = [UIColor colorWithRed:213/225.0 green:213/225.0 blue:221/225.0 alpha:1];
    [_bgView3 addSubview:view1];
      CGFloat titleSize = [OAToolBox sizebyText:_dic[@"instructions"] font:13 minsWidth:20];
    UILabel *label11 = [[UILabel alloc]init];
label11.frame = CGRectMake(label1.left, label1.bottom+10,KScreenWidth-20, titleSize);
label11.numberOfLines = 0;
label11.text = [NSString stringWithFormat:@"%@", _dic[@"instructions"] ];
label11.textColor = [UIColor blackColor];
     label11.font = [UIFont systemFontOfSize:13];
    [_bgView3 addSubview:label11];
              self.bgView3.frame =  CGRectMake(5, 5, KScreenWidth - 10, titleSize+50);

    return cell;


}


}
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{if (indexPath.row == 0){
      CGFloat titleSize = [OAToolBox sizebyText:_dic[@"productContent"] font:13 minsWidth:20];

return titleSize+150+20;

}
if (indexPath.row == 1){

return 140+20+10;

}
else{

      CGFloat titleSize = [OAToolBox sizebyText:_dic[@"instructions"] font:13 minsWidth:20];
return titleSize+50+20;

}


}
- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}


@end
